import { RouterUtil } from "ys-ts/src/vue/router";

import { useAppRouter, useAppRouterName } from "@/plugins/router/app";
import { getLogger } from "ys-ts/src/ts/log";

const logger = getLogger("app.plugin.router");

export interface IToNameConfig {
  name: string;
  params?: any;
}

export function useRouterName() {
  return {
    ...useAppRouterName(),
  };
}

function initRoute() {
  logger(`init`);

  const routerUtil = new RouterUtil();
  const { cfgHome, cfgSecond } = useAppRouter();

  routerUtil.addConfig(cfgHome.build());
  routerUtil.addConfig(cfgSecond.build());

  return routerUtil;
}

export function createRouter() {
  return initRoute().build();
}
